import logging
import traceback


class MyLogging(object):
    # 初始化日志
    def __init__(self):
        logging.basicConfig(
            level=logging.INFO,
            format='%(asctime)s - %(levelname)s - %(message)s',
            filename='download_video.txt',
            filemode='a'
        )

    def write_logger(self, content):
        s = traceback.extract_stack()
        logging.info(str(s[-2]) + content)

    def error_logger(self, content):
        s = traceback.extract_stack()
        logging.error(str(s[-2]) + content)
